package study.api.server;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.security.Principal;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author xiaob@lensysn.com
 * @date 2017/9/12
 */
@RestController
@RequestMapping("/api")
public class ApiController {
    @RequestMapping({ "/user", "/me" })
    public Map<String, String> user(Principal principal) {
        Map<String, String> map = new LinkedHashMap<String, String>();
        map.put("name", principal.getName());
        map.put("get_date","http://127.0.0.1:8000/api/date");
        return map;
    }

    @RequestMapping({ "/date"})
    public Date date(Principal principal) {
        return new Date();
    }
}
